package com.dynamixsoftware.printershare.mdns;

import java.io.IOException;
import java.net.InetAddress;
import java.util.List;

public abstract class DnsRecord
  extends DnsEntity
{
  long created;
  InetAddress source;
  int ttl;
  
  DnsRecord(String paramString, int paramInt1, int paramInt2, int paramInt3)
  {
    super(paramString, paramInt1, paramInt2);
    this.ttl = paramInt3;
    this.created = System.currentTimeMillis();
  }
  
  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof DnsRecord)) && (sameAs((DnsRecord)paramObject));
  }
  
  long getExpirationTime(int paramInt)
  {
    return this.created + 10L * (paramInt * this.ttl);
  }
  
  public InetAddress getRecordSource()
  {
    return this.source;
  }
  
  int getRemainingTTL(long paramLong)
  {
    return (int)Math.max(0L, (getExpirationTime(100) - paramLong) / 1000L);
  }
  
  public int getTtl()
  {
    return this.ttl;
  }
  
  public boolean isExpired(long paramLong)
  {
    return getExpirationTime(100) <= paramLong;
  }
  
  boolean isStale(long paramLong)
  {
    return getExpirationTime(50) <= paramLong;
  }
  
  void resetTTL(DnsRecord paramDnsRecord)
  {
    this.created = paramDnsRecord.created;
    this.ttl = paramDnsRecord.ttl;
  }
  
  boolean sameAs(DnsRecord paramDnsRecord)
  {
    return (super.equals(paramDnsRecord)) && (sameValue(paramDnsRecord));
  }
  
  boolean sameType(DnsRecord paramDnsRecord)
  {
    return this.type == paramDnsRecord.type;
  }
  
  abstract boolean sameValue(DnsRecord paramDnsRecord);
  
  public void setRecordSource(InetAddress paramInetAddress)
  {
    this.source = paramInetAddress;
  }
  
  public void setTtl(int paramInt)
  {
    this.ttl = paramInt;
  }
  
  boolean suppressedBy(DnsPacketIn paramDnsPacketIn)
  {
    int j;
    for (int i = paramDnsPacketIn.numAnswers;; i = j)
    {
      j = i - 1;
      if (i > 0)
      {
        if (suppressedBy((DnsRecord)paramDnsPacketIn.answers.get(j))) {
          return true;
        }
      }
      else {
        return false;
      }
    }
  }
  
  boolean suppressedBy(DnsRecord paramDnsRecord)
  {
    return (sameAs(paramDnsRecord)) && (paramDnsRecord.ttl > this.ttl / 2);
  }
  
  abstract void write(DnsPacketOut paramDnsPacketOut)
    throws IOException;
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.mdns.DnsRecord
 * JD-Core Version:    0.7.0.1
 */